#include "Utils.h"

string toString(int n) {
	ostringstream result;
	result << n;
	return result.str();
}

int toInt(const string& s) {
	int result;
	istringstream ss( s );
	ss >> result;
	if (!ss) throw invalid_argument("toInt");
	return result;
}

string getFileName(const string& path)
{
	return path.substr(path.find_last_of('/') +1 );
}

bool fileExists(const string& filePath) {
    ifstream stream;
    stream.open(filePath.c_str(), ios::in);
    bool exists = stream.is_open();
    stream.close();
    return exists;
}

string formatearPath(string path)
{
	size_t pos = path.find("'");
	if(pos != string::npos){
		path.erase(pos, 1);
		pos = path.find("'");
		if(pos != string::npos)
				path.erase(pos, 1);
	}
	return path;
}
